<?php
//单例模式：先定义一个保护或私有的静态变量和构造方法，再定义一个静态方法来实现实例化本身，保存到静态变量中
class Database{
    protected static $db;
    private function __construct(){
        var_dump('__FILE__');
    }
    static function getInstance(){
        if(self::$db){
            return self::$db;
        }else{
            self::$db = new self();
            return self::$db;
        }
    }
}

$one = Database::getInstance();
$two = Database::getInstance();
$tree =Database::getInstance();